//
//  FadeWindowController.m
//  MagicMonitor
//
//  Created by Stefano Pigozzi on 07/08/08.
//  Copyright 2008 __MyCompanyName__. All rights reserved.
//

#import "FadeWindowController.h"
#import <QuartzCore/QuartzCore.h>

@implementation FadeWindowController
@synthesize window;

- (BOOL)windowShouldClose:(id)window
{
    // Animate the window's alpha value so it fades out.
    [self.window.animator setAlphaValue:0.0];
	// Don't close the window immediately so we can see the animation.
    return NO;
}

- (void)awakeFromNib 
{
    CAAnimation *anim = [CABasicAnimation animation];
    [anim setDelegate:self];
    [self.window setAnimations:[NSDictionary dictionaryWithObject:anim forKey:@"alphaValue"]];
}


- (void)animationDidStop:(CAAnimation *)animation finished:(BOOL)flag 
{
    //if(self.window.alphaValue == 0.00) [self close]; //detect end of fade out and close the window
}

@end